package com.tenton.service;

import com.tenton.exception.DataNullPointerException;
import com.tenton.exception.AgeFormatException;
import com.tenton.pojo.Student;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.ui.Model;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @Date: 2021/2/2
 * @Author: Tenton
 * @Description:
 */
public interface StudentService {
    /**
     * 增加学生
     * @param name
     * @param idCard
     * @param age
     * @param address
     * @param timestamp
     * @param session
     * @return
     */
    Map<String,String> insertStudent(String name, String idCard, int age, String address, Timestamp timestamp, HttpSession session) throws AgeFormatException, DataNullPointerException;

    /**
     * 批量插入学生
     * @param file
     * @param session
     * @return
     */
    Map<String,String> addStudent(MultipartFile file, HttpSession session) throws IOException, AgeFormatException, DataNullPointerException;

    /**
     * 下载模板
     * @param fileName
     */
    void downTemplate(String fileName) throws IOException;
    /**
     * 删除学生
     * @param id
     * @return
     */
    Map<String,String> deleteStudent(Integer id);

    /**
     * 跳转到修改界面
     * @param id
     * @param model
     * @param session
     */
    void toUpdateStudent(Integer id, Model model,HttpSession session);
    /**
     * 修改学生
     * @param stuId
     * @param stuName
     * @param idCard
     * @param age
     * @param address
     * @param session
     * @return
     */
    Map<String,String> updateStudent(int stuId,String stuName,String idCard,int age,String address, HttpSession session) throws DataNullPointerException, AgeFormatException;

    /**
     * 获取所有学生
     * @return
     */
    List<Student> listStudent();

    /**
     * 通过学生编码查询学生
     * @param id
     * @return
     */
    Student getStudent(int id);

    /**
     * 查询真实对象，而不是动态代理对象
     * @param id
     * @return
     */
    Student findByStuId(int id);

    /**
     * 分页查询
     * @param pageNum
     * @param model
     * @return
     */
    void findAll(Integer pageNum,Model model);

    /**
     * 模糊查询
     * @param name
     * @param pageNum
     * @param model
     * @return
     */
    void pageQuery(String name, Integer pageNum,Model model);

    /**
     * 导出学生数据
     * @param response
     * @return
     */
    XSSFWorkbook exportData(HttpServletResponse response);

    /**
     * 跳转到主页
     * @param id
     * @return
     */
    Map<String,String> retMain(Integer id);
}
